/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agil.calculadora.view;

import com.agil.calculadora.operacao.Divisao;
import com.agil.calculadora.operacao.Multiplicacao;
import com.agil.calculadora.operacao.Soma;
import com.agil.calculadora.operacao.Subtracao;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 *
 * @author Anderson
 */
public class CalculadoraView extends javax.swing.JFrame {

    /**
     * Creates new form CalculadoraView
     */
    public CalculadoraView() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jTextValor1 = new javax.swing.JTextField();
        jTextValor2 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabelResultado = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Calculadora");
        setMinimumSize(new java.awt.Dimension(610, 470));
        getContentPane().setLayout(null);

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.setLayout(null);

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setLayout(null);

        jTextValor1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jPanel2.add(jTextValor1);
        jTextValor1.setBounds(20, 40, 320, 60);

        jTextValor2.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jTextValor2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextValor2ActionPerformed(evt);
            }
        });
        jPanel2.add(jTextValor2);
        jTextValor2.setBounds(20, 150, 320, 60);

        jLabel1.setText("VALOR 2");
        jPanel2.add(jLabel1);
        jLabel1.setBounds(20, 120, 90, 14);

        jLabel2.setText("VALOR 1");
        jPanel2.add(jLabel2);
        jLabel2.setBounds(20, 10, 90, 20);

        jPanel1.add(jPanel2);
        jPanel2.setBounds(10, 10, 370, 250);

        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel3.setLayout(null);

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jButton1.setText("/");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton1);
        jButton1.setBounds(30, 280, 120, 60);

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jButton2.setText("+");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton2);
        jButton2.setBounds(30, 20, 120, 60);

        jButton3.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jButton3.setText("-");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton3);
        jButton3.setBounds(30, 100, 120, 60);

        jButton4.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jButton4.setText("*");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton4);
        jButton4.setBounds(30, 190, 120, 60);

        jPanel1.add(jPanel3);
        jPanel3.setBounds(400, 10, 180, 380);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "RESULTADO"));
        jPanel4.setLayout(null);

        jLabelResultado.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jPanel4.add(jLabelResultado);
        jLabelResultado.setBounds(30, 30, 310, 50);

        jPanel1.add(jPanel4);
        jPanel4.setBounds(10, 290, 370, 0);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(0, 0, 600, 420);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextValor2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextValor2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextValor2ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

        Soma objS = new Soma(Double.parseDouble(jTextValor1.getText()),Double.parseDouble(jTextValor2.getText()));
        try {
            objS.executar();
            jLabelResultado.setText(String.valueOf(objS.getResultado()));
        } catch (Exception ex) {
            Logger.getLogger(CalculadoraView.class.getName()).log(Level.SEVERE, null, ex);
        }

        
       
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        Subtracao objS = new Subtracao(Double.parseDouble(jTextValor1.getText()),Double.parseDouble(jTextValor2.getText()));
        try {
            objS.executar();
            jLabelResultado.setText(String.valueOf(objS.getResultado()));
        } catch (Exception ex) {
            Logger.getLogger(CalculadoraView.class.getName()).log(Level.SEVERE, null, ex);
        }

     
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        Multiplicacao objS = new Multiplicacao(Double.parseDouble(jTextValor1.getText()),Double.parseDouble(jTextValor2.getText()));
        try {
            objS.executar();
            jLabelResultado.setText(String.valueOf(objS.getResultado()));
        } catch (Exception ex) {
            Logger.getLogger(CalculadoraView.class.getName()).log(Level.SEVERE, null, ex);
        }

     
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        Divisao objS = new Divisao(Double.parseDouble(jTextValor1.getText()),Double.parseDouble(jTextValor2.getText()));
        try {
            objS.executar();
            jLabelResultado.setText(String.valueOf(objS.getResultado()));
        } catch (Exception ex) {
            Logger.getLogger(CalculadoraView.class.getName()).log(Level.SEVERE, null, ex);
        }

     
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CalculadoraView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CalculadoraView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CalculadoraView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CalculadoraView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CalculadoraView().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabelResultado;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JTextField jTextValor1;
    private javax.swing.JTextField jTextValor2;
    // End of variables declaration//GEN-END:variables
}
